import React from 'react'
import { useNavigate } from 'react-router-dom'
import { Button } from 'antd'
import { useAppDispatch } from '/@/hooks'

import { persist } from '/@/features/account/accountSlices'

const Login: React.FC<{}> = () => {
  const dispatch = useAppDispatch()
  const navigate = useNavigate()

  const doLogin = () => {
    dispatch(persist({ username: 'admin' }))
    console.log('dispatch')
    navigate('/home')
  }

  return (
    <div className="LoginPage">
      <Button type="primary" onClick={doLogin}>
        登录
      </Button>
    </div>
  )
}

export default Login
